﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StockMatch.Host.WindowsService;

namespace StockMatch.Host
{
    public class ConsoleHost : ConsoleBase
    {
        public static int GetAppSetting(string key, int defaultValue)
        {

            string s = ConfigurationManager.AppSettings[key];
            if (s == null) return defaultValue; //说明没有配置过

            return Convert.ToInt32(s);//如果无法转化，一定要自动抛出异常
        }
        public override void Start()
        {
            StockMatch.Init();

            Wcf.OpenServiceHost<IStockMatch, StockMatch>(GetAppSetting("ServicePort", 2005), "IStockMatch");
            while (true)
            {
                Console.ReadLine();
            }
        }
    }
}
